<template>
  <div class="cart_list_item">
    <!-- 左侧勾选状态 -->
    <div class="check-content">
      <check-button
        class="check-btn"
        ref="checkButtonRef"
        :isChecked="itemData.checked"
        @click.native="checkClick"
      />
    </div>
    <!-- 商品图片 -->
    <div class="item_img" @click="checkClick">
      <img :src="itemData.image" alt="" />
    </div>
    <!-- 商品信息 -->
    <div class="item_info" @click="infoClick(itemData)">
      <p class="item_title">{{ itemData.title }}</p>
      <p class="item_desc">{{ itemData.desc }}</p>
      <span class="item_price">￥{{ itemData.price }}</span>
      <span class="item_count">x{{ itemData.count }}</span>
    </div>
  </div>
</template>
<script>
import CheckButton from "components/content/checkButton/CheckButton";

export default {
  name: "CartListItem",
  props: {
    itemData: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  components: {
    CheckButton
  },
  methods: {
    checkClick() {
      // 切换商品选中状态
      this.itemData.checked = !this.itemData.checked;
    },
    //信息点击事件
    infoClick(item) {
      // this.$router.push("/detail/" + item.iid);
    }
  }
};
</script>

<style scoped>
.cart_list_item {
  width: 100%;
  height: 5.5rem;
  display: flex;
  justify-content: space-between;
  padding: 0.4rem;
  padding-left: 0rem;
  border-bottom: 0.04rem solid rgba(128, 128, 128, 0.4);
}
.check-content {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
}
.check-btn {
  width: 20px;
}
.item_img {
  display: flex;
  align-items: flex-start;
  width: 80px;
  height: 100%;
  border-radius: 10px;
  overflow: hidden;
}
.item_img img {
  width: 100%;
  height: auto;
  border-radius: 0.4rem;
}

.item_info {
  position: relative;
  width: calc(100% - 126px);
  margin-left: 0.4rem;
}
.item_info p {
  display: inline-block;
  width: 100%;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.item_title {
  font-size: 0.75rem;
  padding-bottom: 0.5rem;
}
.item_desc {
  font-size: 0.6rem;
  color: gray;
}
.item_price {
  position: absolute;
  left: 0;
  bottom: 0.4rem;
  font-size: 0.75rem;
  color: orangered;
}
.item_count {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  font-size: 0.75rem;
}
</style>
